/*
    DESCRIPTION HERE
 */

#include "led_effects.h"

int redPin = 12;    // LED connected to digital pin 13
int greenPin = 11;
int bluePin = 10;

int knobPin = 0; // analog in pin for potentiometer

int delayTime = 0; // used for potentiometer data
int trigger = 0; // function to run
int lastTrigger = 0;

// How many times to run each LED effect
int loopMax = 100;
int at = 0; // counter for above

// Set to 1 to enable serial debugging, be sure to set baud, too
int debug = 1;
int debug_baud = 9600;

/* END CONFIGURATION */

// Create LED_Effects instance and seed RNG
LED_Effects le(redPin, greenPin, bluePin);

void setup() {
  
  randomSeed(analogRead(5));
  Serial.begin(debug_baud);
  
  Serial.println("variable_led setup completed");

}


void loop()                     
{
  
  delayTime = analogRead(knobPin);

  // if button was just pressed, get new random function
  if (at >= loopMax)
  {
    // ensure different trigger each press
    while (trigger == lastTrigger)
    {
      trigger = random(1, 6);
    }

    lastTrigger = trigger;
    le._reset(); // reset counters in LED_Effects instance
    
    at = 1;

  }

  switch (trigger)
  {

  case 1:
    Serial.println("Trigger 1: downStep");
    le.downStep();
    break;

  case 2:
    Serial.println("Trigger 2: downUp");
    le.downUp();
    break;

  case 3:
    Serial.println("Trigger 3: upStep");
    le.upStep();
    break;

  case 4:
    Serial.println("Trigger 4: allBlink");
    le.allBlink();
    break;

  case 5:
    Serial.println("Trigger 5: scroll");
    le.scroll();
    break;

  case 6:
    Serial.println("Trigger 6: bounce");
    le.bounce();
    break;

  default:
    trigger = 0;
    break;

  }

  at++;
  delay(delayTime);

}

